import App from './App'
import store from './store'
import {
	myRequest
} from '@/common/api.js'
Vue.prototype.$myRequest = myRequest;

import '@/components/uni.promisify.adaptor'

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)

import globalUtil from "@/util/util.js";
Vue.prototype.globalUtil=globalUtil;
Vue.prototype.$noClicks=globalUtil.noMultipleClicks;

import messageApi from "@/util/localMessage/message.js";
Vue.prototype.messageApi=messageApi;

//表单验证
import bjxForm from '@/components/bjx-form/bjx-form.vue';
import bjxFormItem from '@/components/bjx-form/bjx-form-item.vue'
Vue.component('bjxForm', bjxForm);
Vue.component('bjxFormItem', bjxFormItem);

const version = '1.17';
Vue.prototype.$version = version;

/** 判断用户是否登录
 * @method isLogin
 * @param {Boolean} forcedLogin 是否需要强制登录,默认为false
 * @param {Boolean} relaunch 是否关闭所有页面，再打开新页面,默认为false
 */
const isLogin = () => {
	if (store.state.hasLogin === false) {
		msg('尚未登录，请先登录！');
		setTimeout(() => {
			uni.reLaunch({
				url: '/pages/login/login'
			})
		}, 600)

		return false;
	}
	return true;
}

const msg = (title, icon = 'none', duration = 1500, mask = false) => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const domain = "http://shops.hnliandesy.com/";
const baseUrl = "http://shops.hnliandesy.com/api/";

// const domain = "http://www.sh006.com/";
// const baseUrl = "http://www.sh006.com/api/";
const downLoadUrl = "https://liande.oss-cn-beijing.aliyuncs.com/download/htbsc.apk";

Vue.prototype.$api = {
	msg,
	domain,
	isLogin,
	baseUrl,
	downLoadUrl
};

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
Vue.prototype.$store=store
App.mpType = 'app'
const app = new Vue({
    ...App,
	store
})
app.$mount()
// #endif


// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif